package com.guigu.www.controller.yinBo;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.guigu.www.dao.bean.TMember;
import com.guigu.www.dao.bean.TOrder;
import com.guigu.www.dao.bean.TSetmeal;
import com.guigu.www.service.TMemberService;
import com.guigu.www.service.TOrderService;
import com.guigu.www.service.TSetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 预约表 前端控制器
 * </p>
 *
 * @author abo
 * @since 2021-06-22
 */
@RestController
@CrossOrigin
@RequestMapping("/tOrder")
public class TOrderController {

    @Autowired
    TMemberService tMemberService;

    @Autowired
    TOrderService service;

    @Autowired
    TSetmealService tSetmeal;

    @GetMapping("/{id}")
    public TMember x(@PathVariable("id") int id){
        EntityWrapper<TMember> wrapper = new EntityWrapper<TMember>();
        wrapper.eq("id",id);

        TMember tMember = tMemberService.selectOne(wrapper);
        return tMember;

    }



    @GetMapping("/myyuyue/{id}")
    public List<TOrder> q(@PathVariable("id") int id){
        System.out.println("id"+id);
        EntityWrapper<TOrder> wrapper = new EntityWrapper<TOrder>();

        wrapper.eq("member_id",id);
        List<TOrder> tOrders = service.selectList(wrapper);

        ArrayList<Integer> tsetids = new ArrayList<Integer>();
        for (TOrder x:tOrders) {
            tsetids.add(x.getSetmealId());
            TSetmeal tSetmeal = this.tSetmeal.selectById(x.getSetmealId());
            x.setTaocanmingzi(tSetmeal.getName());
        }
        return  tOrders;
    }
}

